<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <title>列表</title>
    <link href="__STATIC__/component/pear/css/pear.css" rel="stylesheet"/>
</head>
<body class="pear-container">

<div class="layui-card">
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:check_auth('add')}"
               data-auth-edit="{:check_auth('edit')}"
               data-auth-delete="{:check_auth('del')}"
               data-auth-modify="{:check_auth('multi')}"
        ></table>
    </div>
</div>

<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['aphpTable'], function () {
        var aphpTable = layui.aphpTable;
        var $ = layui.$;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
            modify_url: "{:url('multi')}",
        };

        aphpTable.render({
            init: init,
            url: "{:url('index')}",
            toolbar: ['refresh_table', 'add', 'enable', 'disable', 'delete'],
            search: true,
            cols: [[
                {type: 'checkbox'},
                {title: '排序', field: 'sort', search: false, edit: 'text'},
                {title: 'ID', field: 'id'},
                {title: '标签', field: 'label', searchOp: 'like'},
                {title: '标题', field: 'field_title', searchOp: 'like'},
                {title: '名称', field: 'field_name', searchOp: 'like'},
                {title: '类型', field: 'field_type', search: false, templet: '<div>{{d.field_type}}({{d.field_length}})</div>'},
                {title: '默认值', field: 'field_value', search: false},
                {title: '表单类型', field: 'form_type', search: false},
                {title: '类别', field: 'type_id', templet:aphpTable.formatter.label, selectList: { 0:'可选',1:'必须',2:'自增ID'} },
                {title: '状态', field: 'status', align: 'center', unresize: true, templet: aphpTable.formatter.switch},
                {
                    title: '操作',
                    align: 'center',
                    width: 120,
                    templet: aphpTable.formatter.tool,
                    operat: ['edit', 'delete']
                }
            ]],
            page: {}
        });
        aphpTable.bindEvent();
    });
</script>
</body>
</html>